package com.tuozixuan.camel.timer;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class TimerDemoRoute extends RouteBuilder {

	@Override
	public void configure() {
	    
	    // 只触发一次
	    //from("timer:firedOnceTimer?repeatCount=1").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	    
	    // 触发指定次数（5次)，默认的触发间隔为1000毫秒
	    //from("timer:firedOnceTimer?repeatCount=5").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	
	    // 触发指定次数（5次)，每次触发间隔为3000毫秒
	    //from("timer:firedOnceTimer?repeatCount=5&period=3000").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	
	    // 一直触发
	    //from("timer:firedOnceTimer?repeatCount=0").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	    //from("timer:firedOnceTimer?repeatCount=-1").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	
	    // 第一次触发延迟3000毫秒，触发指定次数（5次)
	    //from("timer:firedOnceTimer?delay=3000&repeatCount=5").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	
	    // 在指定时间进行第一次触发，之后默认的触发间隔为1000毫秒
	    //from("timer:firedOnceTimer?time=2022-09-10 14:42:00").transform().method("customTimerProcessor", "saySomething").to("stream:out");
	}

}
